import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 */
public class TestDemo {
    public static void main(String[] args) {
        System.out.println("请输入盘子数：");
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        char pos1 = 'A';
        char pos2 = 'B';
        char pos3 = 'C';
        Hanoi(pos1,pos2,pos3,n);
    }

    public static void move(char A,char B){
        System.out.println(A+"->"+B);
    }

    public static void Hanoi(char pos1,char pos2,char pos3,int n){
        if(n == 1){
            move(pos1,pos3);
        }else{
            Hanoi(pos1,pos3,pos2,n-1);
            move(pos1,pos3);
            Hanoi(pos2,pos1,pos3,n-1);
        }
    }
}
